//
// Created by linfe on 2023/6/5.
//
#include "RingBuffer.h"

void ShowRingBuffer(const RingBuffer<int> &buffer) {
    printf("header=%d tail=%d, full %d, size %ld\t ", buffer._header, buffer._tail, buffer.Full(), buffer.Size());
    for (int i = 0; i < buffer.Size(); ++i) {
        printf("%d ", buffer[i]);
    }
    printf("\n");
}


int main(int argc, char **argv) {
    printf("%d\n",(0+6-1)%6);
    int test_length = 5;
    RingBuffer<int> buffer(test_length);
    for (int i = 0; i < test_length * 2; ++i) {
        buffer.EnQueue(i + 1);
        printf("enqueue %d :", i + 1);
        ShowRingBuffer(buffer);
    }
    for (int i = 0; i < test_length + 1; ++i) {
        if (!buffer.Empty()) {
            auto d = buffer.DeQueue();
            printf("dequeue %d :", d);
        } else {
            printf("buffer is empty");
        }
        ShowRingBuffer(buffer);
    }
}
